package src.io;

import java.io.*;

/*
缓冲流高级流作用时加快读写效率
bufferedInputStream缓冲输入流
bufferedOutputStream缓冲输出流
 */
public class CopyDemo3Buffered {
        public static void main(String[] args) throws IOException {
                FileInputStream fis=new FileInputStream("zsw.jpg");
                BufferedInputStream bis=new BufferedInputStream(fis);
                FileOutputStream fos=new FileOutputStream("zsw_cp3.jpg");
                BufferedOutputStream bos=new BufferedOutputStream(fos);
                long start=System.currentTimeMillis();
                int data;
                while ((data=bis.read())!=-1){//使用缓冲流读取字节
                        bos.write(data);//使用缓冲流写出字节
                }
                long end=System.currentTimeMillis();
                System.out.println("复制完毕!耗时："+(end-start)+"ms");
                bis.close();//只需要关闭高级流
                bos.close();
        }
}
